/**
 * @description: 观察对象
 * @param {*} obj
 * @return {*}
 */
function observe(obj) {
  for (const key in obj) {
    let inviteValue = obj[key];
    // const funcs = new Set([]);
    const funcs = [];
    Object.defineProperty(obj, key, {
      get: () => {
        if (window.__func && !funcs.includes(window.__func)) {
          funcs.push(window.__func);
        }
        return inviteValue
      },
      set: (val) => {
        inviteValue = val;
        funcs.forEach(func => func());
      }
    });
  }
}

function run(fn) {
  window.__func = fn;
  fn();
  window.__func = null;
}